#include "createcode.h"
#include <ui_createcode.h>
CreateCode::CreateCode(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::CreateCode)
{
    ui->setupUi(this);
    this->command = new Command(this);
    this->status = new Status(this);
    this->strategy = new Strategy(this);
    this->interpreter = new Interpreter(this);
    this->memorandum = new Memorandum(this);
    this->tertiumQuid = new TertiumQuid(this);
    this->templateMethod = new TemplateMethod(this);
    this->modeState = this->strategy;
    this->languageC = new LanguageC(this);
    this->languageCPlus = new LanguageCPlus(this);
    this->languageJava = new LanguageJava(this);
    this->language = this->languageC;
}

CreateCode::~CreateCode()
{
    delete ui;
}

void CreateCode::on_comboBox_currentIndexChanged(int index)
{
    switch (index) {
    case 0:
        this->modeState = this->strategy;
        break;
    case 1:
        this->modeState = this->status;
        break;
    case 2:
        this->modeState = this->command;
        break;
    case 3:
        this->modeState = this->interpreter;
        break;
    case 4:
        this->modeState = this->tertiumQuid;
        break;
    case 5:
        this->modeState = this->memorandum;
        break;
    case 6:
        this->modeState = this->templateMethod;
        break;
    default:
        break;
    }
    this->modeState->Switchaction();
}

void CreateCode::on_comboBox_2_currentIndexChanged(int index)
{
    switch (index) {
    case 0:
        this->language = this->languageC;
        break;
    case 1:
        this->language = this->languageCPlus;
        break;
    case 2:
        this->language = this->languageJava;
        break;
    default:
        break;
    }
    this->language->Show();
}

void CreateCode::on_pushButtonGnerateactionCode_clicked()
{
    this->language->Doaction();
}
